<?php

//计算工资
//author:化缘

header("Content-type: text/html; charset=utf-8");
require('../mysql.php');
require('json.php');



//定义是按照量算的价格


//获取当月的工资   select sum(count) from computebysize where studentid='20141010001' and timebegin>'2014-11-01 00:00:00'
   //测试数据  学号   20141120021
function getallistecome($classid){
	//计算上个月的时间范围
	$year=date("Y");
    $month=date("m");
   
    $worktimebeginer=$year."-".$month."-"."01"." 00:00:00";
    $worktimeend=$year."-".$month."-"."31"." 00:00:00";
    $stringsql="SELECT studentid,count,price,timebegin,timeend FROM computebysize WHERE studentid =  '{$classid}' AND timebegin >'{$worktimebeginer}' AND timebegin < '$worktimeend'";
    $result=mysql_query($stringsql);
    $list=array();
    while ($row = mysql_fetch_assoc($result)) {
       $list[]=$row;
   	
    }
  return $list;
   // echo encode_json($list);
 }

function getpersonalinfo($classid){
   $stringsql="SELECT college FROM allstudent WHERE studentid = '{$classid}' ";
    $result=mysql_query($stringsql);
     $info;
    while ($row = mysql_fetch_assoc($result)) {
      $info=$row['college'];
     
   }
  // print_r($info) ;
   
   $getmoney=getallistecome($classid);
   $Wage=array('college'=>$info,'priceinfo'=>$getmoney,'month'=>date("m"));
   echo encode_json($Wage);
 
}

$name=isset($_POST['name']) ? htmlspecialchars($_POST['name']):'';
 $token=isset($_POST['tokenid']) ? htmlspecialchars($_POST['tokenid']):'';
//测试用例


getpersonalinfo($name);
//getallistecome("20141120021");
?>

